package com.cqc.paoclient.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.cqc.paoclient.http.ApiContants;
import com.cqc.paoclient.ui.aritcle.article.SyntheTicalArticalFrag;
import com.cqc.paoclient.ui.aritcle.other.OtherArticalFrag;

import java.util.List;

/**
 * Created by cui on 2017/11/23.
 */

public class Tab1FragAdapter extends FragmentPagerAdapter {

    private String[] titles;

    public Tab1FragAdapter(FragmentManager fm, String[] titles) {
        super(fm);
        this.titles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        Fragment frag;
        switch (position) {
            case 0:
                frag = new SyntheTicalArticalFrag();
                break;
            case 1://安卓开发
                frag = OtherArticalFrag.getInstance(ApiContants.TID_ANDROID);
                break;
            case 2://程序设计
//                frag = new OtherArticalFrag();
                frag = OtherArticalFrag.getInstance(ApiContants.TID_PROGRAM_DESIGN);
                break;
            case 3://前端
                frag = OtherArticalFrag.getInstance(ApiContants.TID_FRONT);
                break;
            case 4://ios
                frag = OtherArticalFrag.getInstance(ApiContants.TID_IOS);
                break;
            case 5://数据库
                frag = OtherArticalFrag.getInstance(ApiContants.TID_DB);
                break;
            case 6://开发日志
                frag = OtherArticalFrag.getInstance(ApiContants.TID_DEVLOG);
                break;
            case 7://应用推荐
                frag = OtherArticalFrag.getInstance(ApiContants.TID_REC_APPLICATION);
                break;
            case 8://每日一站
                frag = OtherArticalFrag.getInstance(ApiContants.TID_DAILY);
                break;
            default:
                frag = new SyntheTicalArticalFrag();
                break;
        }
        return frag;
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
